<?php
/**
 * Created by PhpStorm.
 * User: fengzi
 * Date: 2019/6/3
 * Time: 14:29
 */

namespace app\vehicle\model;
use think\Model;

class Bus extends Model
{
    public function getDrivingLicenseAttr($value){
        return $value?config('database.img_url').$value:'';
    }
    public function getBeginTimeAttr($value){
        return getTimeInfo($value);
    }
    public function busBusiness(){
        return $this->hasOne('bus_business','id','business_id')->field('id,name,thumb,service_number,score');
    }

    public function brand(){
        return $this->hasOne('bus_brand','id','brand_id')->field('id,name');
    }

    public function busDriver(){
        return $this->hasOne('bus_driver','id','business_id');
    }

    public function orderComment(){
        return $this->hasMany('order_comment','bus_id','id')->with(['user','order_comment_img'])->limit(10);
    }

    public function busImg(){
        return $this->hasMany('bus_img','bus_id','id');
    }
}